package com.sgb.kjwl.view.ui.adapter.manage;

import android.content.Context;
import android.util.TypedValue;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemWebsiteTabFirstBinding;
import com.sgb.link.utils.SizeUtils;
import com.swgk.core.util.PickSelectEntity;

public class TabFirstAdapter extends BaseQuickAdapter<PickSelectEntity, BaseViewHolder> {
    private ItemWebsiteTabFirstBinding mItemBindIng;
    private int mColor;

    private boolean isBig = true;

    public TabFirstAdapter(Context context, int layoutResId) {
        super(layoutResId);
        mColor = context.getResources().getColor(R.color.color_main);
    }

    public void setTabColor(int color) {
        this.mColor = color;
    }

    public void setTextSizeIsBig(boolean isBig) {
        this.isBig = isBig;
    }

    @Override
    protected void convert(BaseViewHolder helper, PickSelectEntity item) {
        mItemBindIng = DataBindingUtil.bind(helper.itemView);
        if (mItemBindIng != null) {
            mItemBindIng.tvTabName.setText(item.getProjectscale());
            if (item.isCheck()) {
                mItemBindIng.tvTabName.setEndColors(mColor, mColor);
            } else {
                mItemBindIng.tvTabName.setColors(R.color.color_main_bg, R.color.color_main_bg);
            }
            mItemBindIng.tvTabName.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources().getDimension(isBig ? R.dimen.sp13 : R.dimen.sp11));
            mItemBindIng.tvTabName.setTextColor(mContext.getResources().getColor(item.isCheck() ? R.color.color_white : R.color.color_title_medium));
            ViewGroup.LayoutParams lp = mItemBindIng.tvTabName.getLayoutParams();
            lp.width = (SizeUtils.getScreenWidth(mContext) - SizeUtils.dp2px(isBig ? 56 : 64)) / (isBig ? 5 : 6);
            mItemBindIng.tvTabName.setLayoutParams(lp);

        }
    }
}
